#ifndef LISO_BUFFER_H_
#define LISO_BUFFER_H_

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <netinet/in.h>
#include <openssl/ssl.h>

#define BUF_SIZE	8192


/* liso buffer */
typedef struct liso_buf_s {
	int buflen;
	int bufsize;
	char *bufptr;
	char *liso_buf;
	int cnt;
} liso_buf_t;

/* client connection state */
typedef struct {
	/* connection info */
	struct sockaddr_in clientaddr;
	int port;
	int is_ssl;
	int is_cgi;
	/* request header info */
	int method;
	char *uri;
	char *version;
	int connclose;
	int contentlen;
	/* request object info */
	struct stat fstat;
	FILE *pFile;
	int mime_type;
	/* liso buffer */
	liso_buf_t *recvbuf;
	liso_buf_t *sendbuf;
	/* ssl info */	
	SSL* client_context;
} client_conn_t;

liso_buf_t *make_new_buf();
int extend_liso_buf(liso_buf_t *);
void free_liso_buf(liso_buf_t *);
char *liso_buf_readline(liso_buf_t *);
int init_cliconn(client_conn_t *);
void clear_cliconn(client_conn_t *);
void reset_cliconn(client_conn_t *);
#endif
